/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * KLogin.java
 *
 * Created on 09.03.2010., 23.54.41
 */

package KLforme;

import klijent.KlijentVeza;

/**
 *
 * @author Dejan
 */
public class KLogin extends javax.swing.JFrame {
 private  KlijentVeza k;
    private KPrikaz kp;
    private KUnos ku;

    /** Creates new form KLogin */
    public KLogin() {
        initComponents();
         k = new KlijentVeza(this);
         k.povezi();
         k.start();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jtfUser = new javax.swing.JTextField();
        jtfPass = new javax.swing.JTextField();
        jbLog = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jlReport = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jmiUnos = new javax.swing.JMenuItem();
        jmiPrikaz = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jbLog.setText("Uloguj se");
        jbLog.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbLogActionPerformed(evt);
            }
        });

        jLabel1.setText("username");

        jLabel2.setText("password");

        jLabel3.setText("STATUS:");

        jlReport.setText("OFFLINE");

        jMenu1.setText("File");

        jmiUnos.setText("unos");
        jmiUnos.setEnabled(false);
        jmiUnos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiUnosActionPerformed(evt);
            }
        });
        jMenu1.add(jmiUnos);

        jmiPrikaz.setText("prikaz");
        jmiPrikaz.setEnabled(false);
        jmiPrikaz.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiPrikazActionPerformed(evt);
            }
        });
        jMenu1.add(jmiPrikaz);

        jMenuBar1.add(jMenu1);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(74, 74, 74)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jbLog)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel3)
                                .addComponent(jLabel1))
                            .addComponent(jLabel2))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(31, 31, 31)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(jtfUser, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jtfPass, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 89, Short.MAX_VALUE)))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jlReport)
                                .addGap(34, 34, 34)))))
                .addContainerGap(159, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jlReport))
                .addGap(60, 60, 60)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtfUser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addGap(28, 28, 28)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtfPass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addGap(41, 41, 41)
                .addComponent(jbLog)
                .addContainerGap(49, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jbLogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbLogActionPerformed
        k.prijaviSe(jtfUser.getText() , jtfPass.getText());
        
    }//GEN-LAST:event_jbLogActionPerformed

    private void jmiUnosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiUnosActionPerformed
        ku=new KUnos(k);
       ku.setVisible(true);
    }//GEN-LAST:event_jmiUnosActionPerformed

    private void jmiPrikazActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiPrikazActionPerformed

        kp =new KPrikaz(k);
        kp.setVisible(true);
    }//GEN-LAST:event_jmiPrikazActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {


                new KLogin().setVisible(true);


            }
        });
    }

    public void goOnline(){
     jmiUnos.setEnabled(true);
           jmiPrikaz.setEnabled(true);
           jlReport.setText("ONLINE");
           this.repaint();

    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JButton jbLog;
    private javax.swing.JLabel jlReport;
    private javax.swing.JMenuItem jmiPrikaz;
    private javax.swing.JMenuItem jmiUnos;
    private javax.swing.JTextField jtfPass;
    private javax.swing.JTextField jtfUser;
    // End of variables declaration//GEN-END:variables

}
